package com.sl.au.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.Account;
import com.sl.au.entity.Role;
import com.sl.au.repository.RoleRepository;
import com.sl.au.service.RoleService;
@Service("RoleService")
@Transactional
public class RoleServiceImpl extends BaseServiceImpl implements RoleService {

	@Autowired
	RoleRepository roleRepository;
	@Override
	public List<Role> getPage(int start, int length, String key, String orderName, String dir) {
		Page<Role> pages=null;
		Pageable pageable=new PageRequest(start/length,length,Sort.Direction.DESC,"createTime");
		pages=roleRepository.findAll(pageable);
		return pages.getContent();
	}
	@Override
	public List<Role> getRoles(int start, int length,String key,String orderName ,String dir){
		Page<Role> pages = null;
		Pageable pageable=new PageRequest(start/length,length, Sort.Direction.DESC,"createTime");
		pages = roleRepository.getRoleName(key, pageable);
		return pages.getContent();
	}
	@Override
	public RoleRepository getRepository() {
		return roleRepository;
	}

}